"""使用try-except代码块来捕获异常"""

# 除法器: ZeroDivisionError
print("Please input two numbers, and then I will divide them.")
print("Enter 'q' to quit.")
while True:
    try:
        first_num = input("Please input the first number:")
        if first_num=='q':
            break
        else:
            first_num = float(first_num)
        second_num = input("Please input the second number:")
        if second_num=='q':
            break
        else:
            second_num = float(second_num)
        answer = first_num / second_num
    except ZeroDivisionError:
        print("You can't divide by zero.")
    else:
        print(answer)


